package com.perfma.xtest.tool.word;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
//import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.util.NumberUtils;
import com.alibaba.excel.write.handler.AbstractCellWriteHandler;
import com.alibaba.excel.write.handler.AbstractSheetWriteHandler;
import com.alibaba.excel.write.handler.CellWriteHandler;
import com.alibaba.excel.write.handler.SheetWriteHandler;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.WriteTable;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteTableHolder;
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xddf.usermodel.chart.*;
import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.usermodel.*;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTDLbls;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Objects;

/**
 * POI EXCEL 饼图
 */
public class ApachePoiPieChartDemo {
//
//    public static void main(String[] args) throws Exception {
//        generateExcel();
//    }
//
//    /**
//     * 生成excel
//     */
//    public static void generateExcel() throws Exception {
//        String path = "/Users/sijunhui/Downloads/hhh.xlsx";
//        ExcelWriter excelWriter = null;
////        String data = "{\"chartDataItemVOList\":[{\"desc\":\"81.25%\",\"x\":\"未解决\",\"y\":\"26\"},{\"desc\":\"9.38%\",\"x\":\"阿萨德ssssss\",\"y\":\"3\"},{\"desc\":\"3.13%\",\"x\":\"测试\",\"y\":\"1\"},{\"desc\":\"3.13%\",\"x\":\"涩\",\"y\":\"1\"},{\"desc\":\"3.11%\",\"x\":\"水电费费\",\"y\":\"1\"},{\"desc\":\"0%\",\"x\":\"已解决\",\"y\":\"0\"},{\"desc\":\"0%\",\"x\":\"解决中\",\"y\":\"0\"},{\"desc\":\"0%\",\"x\":\"是\",\"y\":\"0\"},{\"desc\":\"0%\",\"x\":\"是打\",\"y\":\"0\"},{\"desc\":\"0%\",\"x\":\"问题状态撒旦法撒旦法\",\"y\":\"0\"}],\"chartDataType\":\"BUG_STATUS\",\"title\":\"问题状态占比\",\"xType\":\"STRING\",\"yType\":\"STRING\"}";
////        String data = "{\"chartDataType\":\"BUG_STATUS\",\"title\":\"问题状态占比\",\"xType\":\"STRING\",\"yType\":\"STRING\"}";
////        String data = "{\"chartDataItemVOList\":[{\"x\":\"2021-08-11\",\"y\":\"0\"},{\"x\":\"2021-08-12\",\"y\":\"0\"},{\"x\":\"2021-08-13\",\"y\":\"0\"},{\"x\":\"2021-08-14\",\"y\":\"0\"},{\"x\":\"2021-08-15\",\"y\":\"0\"},{\"x\":\"2021-08-16\",\"y\":\"0\"},{\"x\":\"2021-08-17\",\"y\":\"0\"},{\"x\":\"2021-08-18\",\"y\":\"0\"},{\"x\":\"2021-08-19\",\"y\":\"0\"},{\"x\":\"2021-08-20\",\"y\":\"0\"},{\"x\":\"2021-08-21\",\"y\":\"0\"},{\"x\":\"2021-08-22\",\"y\":\"0\"},{\"x\":\"2021-08-23\",\"y\":\"0\"},{\"x\":\"2021-08-24\",\"y\":\"0\"},{\"x\":\"2021-08-25\",\"y\":\"1\"},{\"x\":\"2021-08-26\",\"y\":\"15\"},{\"x\":\"2021-08-27\",\"y\":\"1\"},{\"x\":\"2021-08-28\",\"y\":\"0\"},{\"x\":\"2021-08-29\",\"y\":\"2\"},{\"x\":\"2021-08-30\",\"y\":\"7\"},{\"x\":\"2021-08-31\",\"y\":\"3\"},{\"x\":\"2021-09-01\",\"y\":\"1\"},{\"x\":\"2021-09-02\",\"y\":\"0\"},{\"x\":\"2021-09-03\",\"y\":\"0\"},{\"x\":\"2021-09-04\",\"y\":\"0\"},{\"x\":\"2021-09-05\",\"y\":\"0\"},{\"x\":\"2021-09-06\",\"y\":\"2\"},{\"x\":\"2021-09-07\",\"y\":\"0\"},{\"x\":\"2021-09-08\",\"y\":\"0\"},{\"x\":\"2021-09-09\",\"y\":\"0\"}],\"chartDataType\":\"BUG_NEW\",\"title\":\"问题新建趋势\",\"xType\":\"STRING\",\"yTitle\":\"数量（个）\",\"yType\":\"LONG\"}";
//        String data = "[{\"chartDataItemVOList\":[{\"desc\":\"81.25 %\",\"x\":\"未解决\",\"y\":\"26\"},{\"desc\":\"9.38 %\",\"x\":\"阿萨德ssssss\",\"y\":\"3\"},{\"desc\":\"3.13 %\",\"x\":\"涩\",\"y\":\"1\"},{\"desc\":\"3.13 %\",\"x\":\"水电费费\",\"y\":\"1\"},{\"desc\":\"3.11%\",\"x\":\"测试\",\"y\":\"1\"},{\"desc\":\"0%\",\"x\":\"已解决\",\"y\":\"0\"},{\"desc\":\"0%\",\"x\":\"解决中\",\"y\":\"0\"},{\"desc\":\"0%\",\"x\":\"是\",\"y\":\"0\"},{\"desc\":\"0%\",\"x\":\"是打\",\"y\":\"0\"},{\"desc\":\"0%\",\"x\":\"问题状态撒旦法撒旦法\",\"y\":\"0\"}],\"chartDataType\":\"BUG_STATUS\",\"chartType\":\"PIE\",\"title\":\"问题状态占比\",\"xType\":\"STRING\",\"yType\":\"STRING\"},{\"chartDataItemVOList\":[{\"desc\":\"62.5 %\",\"x\":\"菜鸟测试\",\"y\":\"20\"},{\"desc\":\"21.88 %\",\"x\":\"qingyang\",\"y\":\"7\"},{\"desc\":\"6.25 %\",\"x\":\"阿打算放\",\"y\":\"2\"},{\"desc\":\"6.25 %\",\"x\":\"aaa\",\"y\":\"2\"},{\"desc\":\"3.12%\",\"x\":\"晴飔灵灵溜溜产品吼吼072801\",\"y\":\"1\"}],\"chartDataType\":\"BUG_WORKSPACE\",\"chartType\":\"PIE\",\"title\":\"问题所属产品占比\",\"xType\":\"STRING\",\"yType\":\"STRING\"},{\"chartDataItemVOList\":[{\"desc\":\"78.13 %\",\"x\":\"中\",\"y\":\"25\"},{\"desc\":\"9.38 %\",\"x\":\"萨\",\"y\":\"3\"},{\"desc\":\"6.25 %\",\"x\":\"优先级aa\",\"y\":\"2\"},{\"desc\":\"3.13 %\",\"x\":\"高\",\"y\":\"1\"},{\"desc\":\"3.11%\",\"x\":\"优先级bb\",\"y\":\"1\"},{\"desc\":\"0%\",\"x\":\"低\",\"y\":\"0\"},{\"desc\":\"0%\",\"x\":\"萨达是否让人rr\",\"y\":\"0\"},{\"desc\":\"0%\",\"x\":\"萨达re\",\"y\":\"0\"},{\"desc\":\"0%\",\"x\":\"fdasdf\",\"y\":\"0\"},{\"desc\":\"0%\",\"x\":\"asdfasd\",\"y\":\"0\"},{\"desc\":\"0%\",\"x\":\"sssss\",\"y\":\"0\"},{\"desc\":\"0%\",\"x\":\"sdfs\",\"y\":\"0\"},{\"desc\":\"0%\",\"x\":\"fee\",\"y\":\"0\"},{\"desc\":\"0%\",\"x\":\"sdfssss\",\"y\":\"0\"},{\"desc\":\"0%\",\"x\":\"sdfsd\",\"y\":\"0\"}],\"chartDataType\":\"BUG_LEVEL\",\"chartType\":\"PIE\",\"title\":\"问题优先级占比\",\"xType\":\"STRING\",\"yType\":\"STRING\"},{\"chartDataItemVOList\":[{\"desc\":\"100%\",\"x\":\"一天以内\",\"y\":\"3\"},{\"desc\":\"0%\",\"x\":\"一天以内\",\"y\":\"0\"},{\"desc\":\"0%\",\"x\":\"三天以内\",\"y\":\"0\"},{\"desc\":\"0%\",\"x\":\"一周以内\",\"y\":\"0\"},{\"desc\":\"0%\",\"x\":\"一周以上\",\"y\":\"0\"}],\"chartDataType\":\"BUG_DURATION\",\"chartType\":\"PIE\",\"title\":\"问题影响时长占比\",\"xType\":\"STRING\",\"yType\":\"STRING\"},{\"chartDataItemVOList\":[{\"desc\":\"50 %\",\"x\":\"压力机\",\"y\":\"2\"},{\"desc\":\"25 %\",\"x\":\"默认应用\",\"y\":\"1\"},{\"desc\":\"25%\",\"x\":\"yy\",\"y\":\"1\"}],\"chartDataType\":\"BUG_APP\",\"chartType\":\"PIE\",\"title\":\"问题关联应用占比\",\"xType\":\"STRING\",\"yType\":\"STRING\"},{\"chartDataItemVOList\":[{\"x\":\"2021-08-11\",\"y\":\"0\"},{\"x\":\"2021-08-12\",\"y\":\"0\"},{\"x\":\"2021-08-13\",\"y\":\"0\"},{\"x\":\"2021-08-14\",\"y\":\"0\"},{\"x\":\"2021-08-15\",\"y\":\"0\"},{\"x\":\"2021-08-16\",\"y\":\"0\"},{\"x\":\"2021-08-17\",\"y\":\"0\"},{\"x\":\"2021-08-18\",\"y\":\"0\"},{\"x\":\"2021-08-19\",\"y\":\"0\"},{\"x\":\"2021-08-20\",\"y\":\"0\"},{\"x\":\"2021-08-21\",\"y\":\"0\"},{\"x\":\"2021-08-22\",\"y\":\"0\"},{\"x\":\"2021-08-23\",\"y\":\"0\"},{\"x\":\"2021-08-24\",\"y\":\"0\"},{\"x\":\"2021-08-25\",\"y\":\"1\"},{\"x\":\"2021-08-26\",\"y\":\"15\"},{\"x\":\"2021-08-27\",\"y\":\"1\"},{\"x\":\"2021-08-28\",\"y\":\"0\"},{\"x\":\"2021-08-29\",\"y\":\"2\"},{\"x\":\"2021-08-30\",\"y\":\"7\"},{\"x\":\"2021-08-31\",\"y\":\"3\"},{\"x\":\"2021-09-01\",\"y\":\"1\"},{\"x\":\"2021-09-02\",\"y\":\"0\"},{\"x\":\"2021-09-03\",\"y\":\"0\"},{\"x\":\"2021-09-04\",\"y\":\"0\"},{\"x\":\"2021-09-05\",\"y\":\"0\"},{\"x\":\"2021-09-06\",\"y\":\"2\"},{\"x\":\"2021-09-07\",\"y\":\"0\"},{\"x\":\"2021-09-08\",\"y\":\"0\"},{\"x\":\"2021-09-09\",\"y\":\"0\"}],\"chartDataType\":\"BUG_NEW\",\"chartType\":\"TREND\",\"title\":\"问题新建趋势\",\"xType\":\"STRING\",\"yTitle\":\"数量（个）\",\"yType\":\"LONG\"},{\"chartDataItemVOList\":[{\"desc\":\"50 %\",\"x\":\"单选a\",\"y\":\"3\"},{\"desc\":\"50%\",\"x\":\"单选b\",\"y\":\"3\"},{\"desc\":\"0%\",\"x\":\"单选c\",\"y\":\"0\"}],\"chartDataType\":\"BUG_CUSTOM_PROPERTY\",\"title\":\"问题单选项占比\",\"xType\":\"STRING\",\"chartType\":\"PIE\",\"yType\":\"STRING\"},{\"chartDataItemVOList\":[{\"desc\":\"33.33 %\",\"x\":\"选项a\",\"y\":\"1\"},{\"desc\":\"66.67%\",\"x\":\"选项s\",\"y\":\"2\"}],\"chartDataType\":\"BUG_CUSTOM_PROPERTY\",\"title\":\"问题多选s占比\",\"xType\":\"STRING\",\"chartType\":\"PIE\",\"yType\":\"STRING\"},{\"chartDataItemVOList\":[{\"desc\":\"80 %\",\"x\":\"a\",\"y\":\"4\"},{\"desc\":\"20%\",\"x\":\"b\",\"y\":\"1\"}],\"chartDataType\":\"BUG_CUSTOM_PROPERTY\",\"title\":\"问题级联占比\",\"xType\":\"STRING\",\"chartType\":\"PIE\",\"yType\":\"STRING\"},{\"chartDataItemVOList\":[],\"chartDataType\":\"BUG_CUSTOM_PROPERTY\",\"title\":\"问题鸡毛属性占比\",\"xType\":\"STRING\",\"chartType\":\"PIE\",\"yType\":\"STRING\"}]";
//        List<ChartDataVOForExcel> list = JSON.parseArray(data, ChartDataVOForExcel.class);
//        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
//        try {
//            excelWriter = EasyExcel
//                    .write(outputStream)
////                    .write(path)
//                    .autoCloseStream(Boolean.FALSE)
//                    // 行宽自适应
////                    .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
//                    .registerWriteHandler(new SimpleColumnWidthStyleStrategy(25))
//                    // 样式
////                    .registerWriteHandler(getWriteHandler())
//                    // 单元格格式
//                    .registerWriteHandler(new CustomCellWriteHandler())
//                    // 忽略"以文本形式储存的数字"的告警检查
//                    .registerWriteHandler(new CustomSheetWriteHandler())
//                    .build();
//            int sheetIndex = 0;
//            for (ChartDataVOForExcel chartDataVO : list) {
//                // 根据数据生成sheet
//                generateSheet(excelWriter, chartDataVO, sheetIndex);
//                sheetIndex++;
//            }
//        } finally {
//            if (excelWriter != null) {
//                excelWriter.finish();
//            }
//        }
//
//
//        ByteArrayInputStream swapStream = new ByteArrayInputStream(outputStream.toByteArray());
//        XSSFWorkbook wb = new XSSFWorkbook(swapStream);
//        FileOutputStream fileOut = null;
//        try {
//            for (int i = 0; i < list.size(); i++) {
//                ChartDataVOForExcel chartDataVO = list.get(i);
//                XSSFSheet sheet = wb.getSheetAt(i);
//                switch (chartDataVO.getChartType()) {
//                    case PIE:
//                        drawingPie(sheet, chartDataVO);
//                        break;
//                    case TREND:
//                        drawingTrend(sheet, chartDataVO);
//                        break;
//                    default:
//                        break;
//                }
//            }
//            fileOut = new FileOutputStream("/Users/sijunhui/Downloads/xxx1.xlsx");
//            wb.write(fileOut);
//        } catch (Exception e) {
//            wb.close();
//            if (Objects.nonNull(fileOut)) {
//                fileOut.close();
//            }
//            if (Objects.nonNull(outputStream)) {
//                outputStream.close();
//            }
//        }
//    }
//
//
//    public static void drawingPie(XSSFSheet sheet, ChartDataVOForExcel chartDataVO) {
//        List<ChartDataItemVO> chartDataItemVOList = chartDataVO.getChartDataItemVOList();
//        if (CollectionUtil.isEmpty(chartDataItemVOList)) {
//            return;
//        }
//
//        Point xStart = new Point(0, 1);
//        Point xEnd = new Point(0, chartDataItemVOList.size());
//        Point yStart = new Point(2, 1);
//        Point yEnd = new Point(2, chartDataItemVOList.size());
//
//        // 创建一个画布
//        XSSFDrawing drawing = sheet.createDrawingPatriarch();
//        // 固定画布大小。[5,2]-[20,30]
//        XSSFClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 5, 2, 20, 30);
//        // 创建一个chart对象
//        XSSFChart chart = drawing.createChart(anchor);
//        // 标题
//        chart.setTitleText(chartDataVO.getTitle());
//        // 标题是否覆盖图表
//        chart.setTitleOverlay(false);
//
//        // 图例位置
//        XDDFChartLegend legend = chart.getOrAddLegend();
//        legend.setPosition(LegendPosition.TOP_RIGHT);
//
//        // 分类轴标数据，
//        XDDFDataSource<String> x = XDDFDataSourcesFactory.fromStringCellRange(sheet, new CellRangeAddress(xStart.getRow(), xEnd.getRow(), xStart.getColumn(), xEnd.getColumn()));
//        // 数据1，
//        XDDFNumericalDataSource<Double> y = XDDFDataSourcesFactory.fromNumericCellRange(sheet, new CellRangeAddress(yStart.getRow(), yEnd.getRow(), yStart.getColumn(), yEnd.getColumn()));
//        XDDFChartData data = chart.createData(ChartTypes.PIE, null, null);
//        // 设置为可变颜色
//        data.setVaryColors(true);
//        // 图表加载数据
//        data.addSeries(x, y);
//
//        // 绘制
//        chart.plot(data);
//        CTDLbls ctdLbls = chart.getCTChart().getPlotArea().getPieChartArray(0).getSerArray(0).addNewDLbls();
//        ctdLbls.addNewShowVal().setVal(true);
//        ctdLbls.addNewShowLegendKey().setVal(false);
//        // 类别名称
//        ctdLbls.addNewShowCatName().setVal(true);
//        ctdLbls.addNewShowSerName().setVal(false);
//        // 百分比
//        ctdLbls.addNewShowPercent().setVal(false);
//        // 引导线
//        ctdLbls.addNewShowLeaderLines().setVal(true);
//        // 分隔符为分行符
//        ctdLbls.setSeparator("\n");
//    }
//
//    public static void drawingTrend(XSSFSheet sheet, ChartDataVOForExcel chartDataVO) {
//        List<ChartDataItemVO> chartDataItemVOList = chartDataVO.getChartDataItemVOList();
//        if (CollectionUtil.isEmpty(chartDataItemVOList)) {
//            return;
//        }
//
//        Point xStart = new Point(0, 1);
//        Point xEnd = new Point(0, chartDataItemVOList.size());
//        Point yStart = new Point(1, 1);
//        Point yEnd = new Point(1, chartDataItemVOList.size());
//
//        // 创建一个画布
//        XSSFDrawing drawing = sheet.createDrawingPatriarch();
//        // 固定画布大小。[5,2]-[20,30]
//        XSSFClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 5, 2, 20, 30);
//        // 创建一个chart对象
//        XSSFChart chart = drawing.createChart(anchor);
//        // 标题
//        chart.setTitleText(chartDataVO.getTitle());
//        // 标题覆盖
//        chart.setTitleOverlay(false);
//
//        // X轴标题位置
//        XDDFCategoryAxis bottomAxis = chart.createCategoryAxis(AxisPosition.BOTTOM);
//        bottomAxis.setTitle(chartDataVO.getXTitle());
//        // Y轴标题位置
//        XDDFValueAxis leftAxis = chart.createValueAxis(AxisPosition.LEFT);
//        leftAxis.setTitle(chartDataVO.getYTitle());
//
//        // X轴数据
//        XDDFDataSource<String> x = XDDFDataSourcesFactory.fromStringCellRange(sheet, new CellRangeAddress(xStart.getRow(), xEnd.getRow(), xStart.getColumn(), xEnd.getColumn()));
//        // Y轴数据
//        XDDFNumericalDataSource<Double> y = XDDFDataSourcesFactory.fromNumericCellRange(sheet, new CellRangeAddress(yStart.getRow(), yEnd.getRow(), yStart.getColumn(), yEnd.getColumn()));
//
//        // LINE：折线图，
//        XDDFLineChartData data = (XDDFLineChartData) chart.createData(ChartTypes.LINE, bottomAxis, leftAxis);
//
//        // 图表加载数据，折线
//        XDDFLineChartData.Series series = (XDDFLineChartData.Series) data.addSeries(x, y);
//        // 直线
//        series.setSmooth(false);
//        // 设置标记大小
//        series.setMarkerSize((short) 6);
//        // 设置标记样式，星星
//        series.setMarkerStyle(MarkerStyle.STAR);
//        // 绘制
//        chart.plot(data);
//    }
//
//    /**
//     * 生成sheet
//     *
//     * @param excelWriter excel操作对象
//     * @param sheetIndex  sheet索引
//     */
//    private static void generateSheet(ExcelWriter excelWriter, ChartDataVOForExcel chartDataVO, int sheetIndex) {
//        String sheetName = chartDataVO.getTitle();
//        WriteSheet writeSheet = EasyExcel.writerSheet(sheetIndex, sheetName).build();
//        generateTable(excelWriter, writeSheet, chartDataVO);
//    }
//
//
//    /**
//     * 生成表格
//     *
//     * @param excelWriter excel操作对象
//     * @param writeSheet  sheet操作对象
//     * @return 表格占用行数
//     */
//    private static void generateTable(ExcelWriter excelWriter, WriteSheet writeSheet, ChartDataVOForExcel chartDataVO) {
//        // 表格名
//        WriteTable writeTable = EasyExcel.writerTable(0).needHead(Boolean.TRUE).build();
//        // 设置表头
//        writeTable.setHead(getTableHeader(chartDataVO));
//
//        // 写入数据
//        excelWriter.write(dataList(chartDataVO.getChartDataItemVOList()), writeSheet, writeTable);
//    }
//
//    /**
//     * 获取表格的表头
//     *
//     * @param chartDataVO 数据
//     * @return 表格的表头
//     */
//    private static List<List<String>> getTableHeader(ChartDataVOForExcel chartDataVO) {
//        switch (chartDataVO.getChartType()) {
//            case PIE:
//                return Lists.newArrayList(Lists.newArrayList("类别"), Lists.newArrayList("数量"), Lists.newArrayList("百分比"));
//            case TREND:
//                return Lists.newArrayList(Lists.newArrayList("日期"), Lists.newArrayList("数量"));
//            default:
//                return Lists.newArrayList();
//        }
//    }
//
//    /**
//     * 获取数据行
//     *
//     * @param dataList 数据
//     * @return 数据行
//     */
//    private static List<List<Object>> dataList(List<ChartDataItemVO> dataList) {
//        List<List<Object>> resultList = Lists.newArrayList();
//        if (CollectionUtil.isEmpty(dataList)) {
//            return resultList;
//        }
//
//        for (ChartDataItemVO o : dataList) {
//            resultList.add(Lists.newArrayList(o.getX(), o.getY(), o.getDesc()));
//        }
//        return resultList;
//    }
//
//
//    static class Point {
//        int column;
//        int row;
//
//        public Point(int column, int row) {
//            this.column = column;
//            this.row = row;
//        }
//
//        public Point() {
//        }
//
//        public int getColumn() {
//            return column;
//        }
//
//        public void setColumn(int column) {
//            this.column = column;
//        }
//
//        public int getRow() {
//            return row;
//        }
//
//        public void setRow(int row) {
//            this.row = row;
//        }
//    }
//
//    /**
//     * 单元格拦截器
//     */
//    static class CustomCellWriteHandler extends AbstractCellWriteHandler {
//        @Override
//        public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<CellData> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
//            // 对单元格格式进行简单处理
//            if (!isHead) {
//                String cellValue = cell.getStringCellValue();
//                if (Strings.isNullOrEmpty(cellValue)) {
//                    return;
//                }
//
//                if (cellValue.contains("%")) {
//                    try {
//                        cell.setCellValue(Double.parseDouble(cellValue.substring(0, cellValue.length() - 1)) / 100);
//                        CellStyle cellStyle = writeSheetHolder.getSheet().getWorkbook().createCellStyle();
//                        DataFormat format = writeSheetHolder.getSheet().getWorkbook().createDataFormat();
//                        cellStyle.setDataFormat(format.getFormat("0.00%"));
//                        cell.setCellStyle(cellStyle);
//                    } catch (Exception e) {
//                        e.printStackTrace();
//                    }
//                } else {
//                    try {
//                        double valueDouble = NumberUtils.parseDouble(cellValue, null);
//                        cell.setCellType(CellType.NUMERIC);
//                        cell.setCellValue(valueDouble);
//                    } catch (Exception e) {
//                        // do noting
//                    }
//                }
//            }
//
//        }
//    }
//
//    /**
//     * sheet拦截器
//     */
//    static class CustomSheetWriteHandler extends AbstractSheetWriteHandler {
//        @Override
//        public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {
//            Sheet sheet = writeSheetHolder.getSheet();
//            try {
//                // 忽略"以文本形式储存的数字"的告警检查
//                Field sh = SXSSFSheet.class.getDeclaredField("_sh");
//                sh.setAccessible(true);
//                XSSFSheet xssfsheet = (XSSFSheet) sh.get(sheet);
//                xssfsheet.addIgnoredErrors(new CellRangeAddress(0, 10000, 0, 1000), IgnoredErrorType.NUMBER_STORED_AS_TEXT);
//            } catch (Exception e) {
//                e.printStackTrace();
//            }
//        }
//    }
}